/* eslint-disable semi */
/* eslint-disable semi */
/* eslint-disable quotes */
<template>
    <van-pull-refresh v-model="isLoading"
                      class="Set-height">
        <div class="TopList">
            <router-link to="/Setup">
                <van-icon class="Backlink"
                          name="arrow-left" />
            </router-link>

            <div class="TopList-span">

                <span> 地址管理 </span>

            </div>

        </div>

        <div class="shadow"> </div>

        <div class="Area-3"
             v-if="!active">
            <div class="hello-1"
                 v-for="(item, index) in middleimages"
                 :key="index">
                <van-image class="hello-1-img"
                           width="3.2rem"
                           height="1.893rem"
                           :src="item.imgSrc" />
                <p>很抱歉！暂无地址</p>
            </div>

        </div>

        <van-list v-model="loading"
                  :finished="finished"
                  finished-text=""
                  @load="onLoad">
            <div class="adderss-list"
                 v-for="(itemlist, index) in Addersslist"
                 :key="index"
                 :class="[itemlist.id !=0? 'gray':'']">
                <div class="address-list-top">
                    <div class="left-icon">
                        <van-icon :name="[itemlist.id !=0? 'passed':'checked']"
                                  :color="[itemlist.id !=0? 'silver':'#41D08C']"
                                  size="24" />
                    </div>

                    <div class="right-text">
                        <span>{{itemlist.name}}</span>
                        <span>{{itemlist.tel}}</span>
                        <span class="add-distance">{{itemlist.postcode}}</span>
                        <span class="reduce-height">{{itemlist.address}}</span>

                    </div>
                </div>

                <div class="address-list-bottom">
                    <van-button class="addborder"
                                icon="certificate"
                                plain
                                type="default"
                                size="mini">设为默认地址</van-button>
                    <van-button class="addborder"
                                icon="edit"
                                plain
                                type="default"
                                size="mini">编辑</van-button>
                    <van-button class="addborder addcolor"
                                icon="delete"
                                plain
                                type="default"
                                size="mini">删除</van-button>
                </div>
            </div>

            <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
        </van-list>

        <div class="lastadd"
             @click="address()">

            <div class="lastadd-icon">
                <van-icon name="add-o"
                          size="20" />
            </div>
            <div class="lastadd-span"><span> 添加地址</span> </div>

        </div>

        <!-- 右侧挂件 -->
        <div class="pendant">

            <div class="pendant-1 "
                 :class="[pendant==1 ? 'add-hidden' :'red-hidden-2' ]"
                 @click="conceal(1)">
                <van-icon name="arrow-left"
                          color="#e3e3e3"
                          size="22" />

            </div>
            <div class="pendant-2"
                 :class="[pendant==0 ? 'add-hidden-2' :'red-hidden' ]">
                <router-link to="/">
                    <div class="pendant-2-child">
                        <van-icon name="shop-o"
                                  color="#e3e3e3"
                                  size="22" />
                    </div>
                </router-link>
                <router-link to="/HamDivision">
                    <div class="pendant-2-child">
                        <van-icon name="shopping-cart-o"
                                  color="#e3e3e3"
                                  size="22" />
                    </div>
                </router-link>
                <router-link to="/Setup">
                    <div class="pendant-2-child">
                        <van-icon name="apps-o"
                                  color="#e3e3e3"
                                  size="22" />
                    </div>
                </router-link>
                <router-link to="/Withdraw ">
                    <div class="pendant-2-child">
                        <van-icon name="balance-o"
                                  color="#e3e3e3"
                                  size="22" />
                    </div>
                </router-link>
                <div class="pendant-2-child"
                     @click="addconcel(0)">
                    <van-icon name="arrow"
                              color="#e3e3e3"
                              size="22" />
                </div>
            </div>

        </div>
    </van-pull-refresh>
</template>

<script>
import TabBar from "./TabBar.vue";

//引入其他子组件
export default {
    components: {
        TabBar
    },
    // eslint-disable-next-line space-before-function-paren
    data() {
        return {
            active: true,
            count: 0,
            isLoading: false,
            index: 0,
            message: "",
            bannerimages: [
                { id: 0, imgSrc: require("../assets/images/a16.jpg") }
                // { id: 1, imgSrc: require("../assets/images/a18.jpg") }
            ],
            middleimages: [{ id: 0, imgSrc: require("../assets/images/none.png") }],
            chosenAddressId: "1",
            loading: false,
            finished: false,
            Addersslist: [
                {
                    id: "0",
                    name: "张三",
                    tel: "13000000000",
                    postcode: "650000",
                    address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室"
                },
                {
                    id: "1",
                    name: "李四",
                    tel: "13000000001",
                    postcode: "650001",
                    address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 502 室"
                },
                {
                    id: "1",
                    name: "王五",
                    tel: "13000000002",
                    postcode: "650002",
                    address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 503 室"
                }
            ],
            pendant: 0
        };
    },

    mounted() {
        // 上拉加载
    },
    // eslint-disable-next-line space-before-function-paren
    // created:vue生命周期中的钩子函数，在这个时间点，data中的数据已经注入到响应式系统中
    created() { },

    methods: {
        address() {
            this.$router.push({ path: "/AddressAdd" });
        },

        afterRead(file) {
            // 此时可以自行将文件上传至服务器
            console.log(file);
        },

        //弹出提示
        showNumber() {
            this.$toast({
                message: "字数不能超过200个"
            });
        },

        onLoad() {
            // 异步更新数据
            // setTimeout 仅做示例，真实场景中一般为 ajax 请求
            setTimeout(() => {
                for (let i = 0; i < 3; i++) {
                    this.list.push(this.list.length + 1);
                }

                // 加载状态结束
                this.loading = false;

                // 数据全部加载完成
                if (this.list.length >= 40) {
                    this.finished = true;
                }
            }, 1000);
        },
        conceal(state) {
            this.pendant = state;
        },
        addconcel(state) {
            this.pendant = state;
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* //自定义.css的样式路径 */
/* @import "../css/HomePage.css"; */

* {
    padding: 0;
    margin: 0;
}
body {
    background-color: #f6f6f6;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    margin: 0;
    display: block;
}
div {
    display: block;
    box-sizing: border-box;
}
.Set-height {
    height: 687px;
}
.shadow {
    height: 8px;
    width: 100%;
    background: #f6f6f6;
}

.TopList {
    display: flex;
    width: 100%;
    height: 50px;
    font-size: 20px;
    text-align: left;
    background: #ffffff;
    line-height: 50px;
}
.Backlink {
    margin-top: 15px;
    margin-left: 15px;
    color: #888;
}
.TopList-span {
    display: flex;
    height: 20px;
    margin-top: 0px;
    margin-left: 110px;
    font-size: 16px;
    width: 60%;
}

.hello-1 {
    width: 100%;
    height: 600px;
    background: #f6f6f6;
}
.hello-1 p {
    margin-top: 18px;
    font-size: 15px;
    color: #bbb;
}
.hello-1-img {
    margin-top: 35px;
    margin-left: 128px;
    border-radius: 10px;
    pointer-events: none;
}
.hello-1-details {
    width: 100%;
    height: auto;
}
.hello-1-details-img {
    border-radius: 10px;
    pointer-events: none;
}

.lastadd {
    position: fixed;
    bottom: 0px;
    background: #37cd87;
    width: 100%;
    height: 50px;
    color: #fff;
    line-height: 50px;
    font-size: 15px;
    display: flex;
}
.lastadd-icon {
    width: 20px;
    height: 30px;
    margin-top: 16px;
    margin-left: 150px;
    display: flex;
}
.lastadd-span {
    width: 80px;
    height: 30px;
    display: flex;
}

.address-list {
    width: 100%;
    height: 200px;
    padding: 3%;
    display: flex;
}

.van-radio__icon {
    width: 50px;
    display: flex;
}
.adderss-list {
    width: 100%;
    height: 180px;
    background: #f6f6f6;
    padding: 5px 12px 1px 12px;
}
.address-list-top {
    width: 100%;
    height: 120px;
    background: #ffffff;
    border-bottom: 1px solid #f6f6f6;
    display: flex;
}

.left-icon {
    height: 100%;
    width: 30px;
    padding-top: 38px;
    padding-left: 10px;
    display: flex;
}
.right-text {
    height: 100%;
    width: 350px;
    line-height: 100%;
    display: flex;
    font-size: 16px;
    flex-direction: row;
    flex-flow: wrap;
    padding-top: 25px;
    padding-left: 15px;
    text-align: left;
}
.right-text span {
    height: 26px;
    line-height: 30px;
    padding-right: 15px;
}
.add-distance {
    padding-left: 61px;
}
.reduce-height {
    margin-top: -20px;
    color: #888;
}

.address-list-bottom {
    width: 100%;
    height: 46px;
    background: #ffffff;
    padding: 13px 0px 10px 100px;
}
.addborder {
    border-radius: 5px;
    border: 1px solid #555555;
    padding: 2px 3px 2px 3px;
    font-size: 12px;
}
.addcolor {
    color: #e95c6f;
    border: 1px solid #e95c6f;
}

.pendant-1 {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: fixed;
    bottom: 24%;
    right: 0;
    z-index: 550;
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
    padding-left: 8px;
}
.add-hidden {
    transform: translate(40px);
    transition: transform 1s ease 0s;
}
.add-hidden-2 {
    transform: translate(0px);
    transition: transform 1s ease 0s;
}
.pendant-2 {
    background: #7b7b7b;
    overflow: hidden;
    position: fixed;
    bottom: 24%;
    right: 0;
    z-index: 550;
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
    justify-content: center;
    text-align: center;
    width: 40px;
    height: 200px;
    flex-flow: row wrap;
    right: -40px;
}

.red-hidden {
    transform: translate(-40px);
    transition: transform 1s ease 0s;
}
.red-hidden-2 {
    transform: translate(0px);
    transition: transform 1s ease 0s;
}

.pendant-2-child {
    flex: none;
    text-align: center;
    border-bottom: 0.1px solid #999;
    width: 25px;
    height: 40px;
    line-height: 40px;
    margin-left: 8px;
    padding-top: 8px;
}
</style>


